/**
 * @FileName: ThemesService.java
 * @Author
 * @Description:
 * @Date 2015年12月28日 下午3:26:32
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.service;

import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import cn.hpclub.server.constant.Constant;
import cn.hpclub.server.util.InterfaceUtil;

public class BannerService extends Service{
    public static BannerService service = new BannerService();

    /**
     * 获取查询语句
     */
    public String getSqlExceptSelect(ConcurrentHashMap<String, String> searchInfo){
        String sqlExceptSelect = "from banner as b where 1=1 and b.is_deleted = 0 ";

        sqlExceptSelect += " and b.org_id in("
                + InterfaceUtil.getChlidOrgIdSql(InterfaceUtil.getOrgId(), Constant.MAX_ORG_LEVEL, true) + ") ";

        for(Entry<String, String> item : searchInfo.entrySet()){
            sqlExceptSelect += buildQuery(item);
        }
        sqlExceptSelect += " order by sort asc";

        // System.out.println("sqlExceptSelect = " + sqlExceptSelect);
        return sqlExceptSelect;
    }

    private String buildQuery(Entry<String, String> item){
        return " and " + item.getKey() + " like '%" + item.getValue() + "%'";
    }
}
